var assert = require("assert")
var resolver = require("sandro/resolver").resolver 

var $ = exports

$.testRegex = function() {
	var rs = resolver()
	
	rs.push(/^ab/, "1")
	rs.push(/^a/, "2")
	rs.push(/./, "3")
	
	assert.equal("1", rs.resolve("abcd"))
	assert.equal("2", rs.resolve("aacd"))
	assert.equal("3", rs.resolve("bacd"))
}

$.testString = function() {
	var rs = resolver()
	
	rs.push(/^ab/, "1")
	rs.push("a", "2")
	rs.push(/./, "3")
	
	assert.equal("1", rs.resolve("abcd"))
	assert.equal("2", rs.resolve("aacd"))
	assert.equal("3", rs.resolve("bacd"))
}

$.testShortPathOnStringRule = function() {
	var rs = resolver()
	rs.push("/aaaa", "1")
	rs.push("/","2")
	
	assert.equal("2", rs.resolve(new java.lang.String("/xa")))
}